/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.acme.business;

import com.acme.model.StockPrice;
import com.acme.persistence.StockPriceDao;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author General
 */
public class StockPriceBusinessImpl implements StockPriceBusiness {
    @Autowired
    private StockPriceDao stockPriceDao;
    
    @Transactional
    public void createStockPrice(StockPrice stockPrice) {
        
        stockPriceDao.create(stockPrice);
    }
    
    @Transactional
    @Override
    public void createStockPrice(long stock_id, long market_id, String priceDate, String openPrice, String highPrice, String lowPrice, String closePrice, String volume, String adjustedClosePrice) {
        StockPrice stockPrice = new StockPrice(stock_id, market_id, priceDate, openPrice, highPrice, lowPrice, closePrice, volume, adjustedClosePrice);
        stockPriceDao.create(stockPrice);
    }

    @Transactional
    @Override
    public void deleteStockPrice(long stock_id) {
        // validaciones
        StockPrice stockPrice = new StockPrice();
        stockPrice.setStock_id(stock_id);
        stockPriceDao.delete(stockPrice);
    }

    @Transactional
    @Override
    public void updateStockPrice(long stock_id, long market_id, String priceDate, String openPrice, String highPrice, String lowPrice, String closePrice, String volume, String adjustedClosePrice) {
        // validaciones de negocio
        StockPrice stockPrice = new StockPrice();
        stockPrice.setStock_id(stock_id);
        stockPriceDao.update(stockPrice);
    }
    
    @Transactional
    @Override
    public StockPrice getStockPrice(long stock_id) {
        return stockPriceDao.findById(stock_id);
    }
    
    @Transactional
    @Override
    public List<StockPrice> getAllStockPrice() {
        return stockPriceDao.findAll();
    }
    
    @Transactional
    @Override
    public void setStockPriceDao(StockPriceDao stockPriceDao) {
        this.stockPriceDao = stockPriceDao;
    }
    
}
